#include"head.h"

void JudgeGender(Information s[], int i)/*判断输入的性别是否正确*/
{
	while(1)
	{
		fflush(stdin);
		printf("性别：");
		gets(s[i].gender);
		
		if (strcmp(s[i].gender, "男")==0||strcmp(s[i].gender, "女")==0)
		{
			break;
		}
		else
		{
			printf("性别请输入男或女\n");
		}
	}
	
	
	return ;
}

void JudgeDay(Information s[], int i)/*判断日期是否输入正确*/
{
	while(1)
	{
			printf("参加工作日期(年):");
			scanf("%d",&s[i].startwork_year);
			if (s[i].startwork_year>0)
			{
				break;
			}
			else
			{
				printf("请重新输入日期：\n");
			}
		}
	
	while(1)
	{
			printf("参加工作日期(月):");
			scanf("%d",&s[i].startwork_month);
			if (s[i].startwork_month>0 && s[i].startwork_month<=12)
			{
				break;
			}
			else
			{
				printf("请重新输入日期：\n");
			}
		}
		
	while(1)
	{
			printf("参加工作日期(日):");
			scanf("%d",&s[i].startwork_day);
				if(s[i].startwork_year%4==0 && s[i].startwork_year%100!=0)
				{
					if(s[i].startwork_month==2)
					{
						if(s[i].startwork_day<=29)
						{
							break;
						}
						else 
						{
							printf("请重新输入日期：\n");
						}
					}
					else if(s[i].startwork_month==1 || s[i].startwork_month==3 || s[i].startwork_month==5 || s[i].startwork_month==7 || s[i].startwork_month==8 || s[i].startwork_month==10 || s[i].startwork_month==12)
					{
						if (s[i].startwork_day<=31)
						{
							break;
						}
						else 
						{
							printf("请重新输入日期：\n");
						}
					}
					else
					{
						if(s[i].startwork_day<=30)
						{
							break;
						}
						else
						{
							printf("请重新输入日期：\n");
						}
					}
				}
				else
				{
					if(s[i].startwork_month==2)
					{
						if(s[i].startwork_day<=28)
						{
							break;
						}
						else 
						{
							printf("请重新输入日期：\n");
						}
					}
					else if(s[i].startwork_month==1 || s[i].startwork_month==3 || s[i].startwork_month==5 || s[i].startwork_month==7 || s[i].startwork_month==8 || s[i].startwork_month==10 || s[i].startwork_month==12)
					{
						if (s[i].startwork_day<=31)
						{
							break;
						}
						else 
						{
							printf("请重新输入日期：\n");
						}
					}
					else
					{
						if(s[i].startwork_day<=30)
						{
							break;
						}
						else
						{
							printf("请重新输入日期：\n");
						}
					}
				}
			
		}
	
	while(1)
	{
			
	
		while(1)
		{
			printf("请输入今天的日期(年)：");
			scanf("%d", &s[i].nowyear);
			if (s[i].nowyear>0)
			{
				break;
			}
			else
			{
				printf("请重新输入日期：\n");
			}
		}
		
		while(1)
		{
			printf("请输入今天的日期(月)：");
			scanf("%d", &s[i].nowmonth);
			if (s[i].nowmonth>0 && s[i].nowmonth<=12)
			{
				break;
			}
			else
			{
				printf("请重新输入日期：\n");
			}
		}
		
		while(1)
		{
			printf("请输入今天的日期(日)：");
			scanf("%d", &s[i].nowday);
			
				if(s[i].nowyear%4==0 && s[i].nowyear%100!=0)
				{
					if(s[i].nowmonth==2)
					{
						if(s[i].nowday<=29)
						{
							break;
						}
						else 
						{
							printf("请重新输入日期：\n");
						}
					}
					else if(s[i].nowmonth==1 || s[i].nowmonth==3 || s[i].nowmonth==5 || s[i].nowmonth==7 || s[i].nowmonth==8 || s[i].nowmonth==10 || s[i].nowmonth==12)
					{
						if (s[i].nowday<=31)
						{
							break;
						}
						else 
						{
							printf("请重新输入日期：\n");
						}
					}
					else
					{
						if(s[i].nowday<=30)
						{
							break;
						}
						else
						{
							printf("请重新输入日期：\n");
						}
					}
				}
				else
				{
					if(s[i].nowmonth==2)
					{
						if(s[i].nowday<=28)
						{
							break;
						}
						else 
						{
							printf("请重新输入日期：\n");
						}
					}
					else if(s[i].nowmonth==1 || s[i].nowmonth==3 || s[i].nowmonth==5 || s[i].nowmonth==7 || s[i].nowmonth==8 || s[i].nowmonth==10 || s[i].nowmonth==12)
					{
						if (s[i].nowday<=31)
						{
							break;
						}
						else 
						{
							printf("请重新输入日期：\n");
						}
					}
					else
					{
						if(s[i].nowday<=30)
						{
							break;
						}
						else
						{
							printf("请重新输入日期：\n");
						}
					}
				}
				
		}
		
		
		if(s[i].nowyear>s[i].startwork_year)
		{
		break;
		}
		else if(s[i].nowyear==s[i].startwork_year&&s[i].nowmonth>s[i].startwork_month)
		{
			break;
				
		}
		else if(s[i].nowyear==s[i].startwork_year&&s[i].nowmonth==s[i].startwork_month&&s[i].nowday>s[i].startwork_day)
		{
			break;
		}
		else
		{
			printf("当前日期输入错误：\n");
			printf("请重新输入日期：\n");
		}
	}
	return ;
}